package com.fjrcloud.controller;

import com.fjrcloud.entity.PriceType;
import com.fjrcloud.service.BasePriceService;
import com.fjrcloud.service.StorefrontStandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


/**
 * Created by shengjian.lin on 17-1-16.
 */
@Controller
@RequestMapping("calculate")
public class HtmlCalculateController {

    @Autowired
    private BasePriceService priceService;
    @Autowired
    private StorefrontStandardService storefrontService;

    @RequestMapping("price")
    public String price(Model model, Integer id){

        model.addAttribute("relocationPrice",priceService.get(PriceType.relocation));
        model.addAttribute("temporaryPrice",priceService.get(PriceType.temporary));
        model.addAttribute("difficultPrice",priceService.get(PriceType.difficult));
        model.addAttribute("landRewardPrice",priceService.get(PriceType.landReward));
        model.addAttribute("signingRewardPrice",priceService.get(PriceType.signingReward));
        model.addAttribute("sealRewardPrice",priceService.get(PriceType.sealReward));
        model.addAttribute("transitionRewardPrice",priceService.get(PriceType.transitionReward));
        model.addAttribute("layer4Price",priceService.get(PriceType.layer4));
        model.addAttribute("layer5Price",priceService.get(PriceType.layer5));
        model.addAttribute("layer6Price",priceService.get(PriceType.layer6));
        model.addAttribute("takeCareOfBuyPrice",priceService.get(PriceType.takeCareOfBuy));
        model.addAttribute("equallySharedPrice",priceService.get(PriceType.equallyShared));
        model.addAttribute("errorAreaPriceBasicPrice",priceService.get(PriceType.errorAreaPriceBasic));
        model.addAttribute("errorAreaPriceSecondaryPrice",priceService.get(PriceType.errorAreaPriceSecondary));
        model.addAttribute("oldManSubsidiesPrice",priceService.get(PriceType.oldManSubsidies));

        return "base-price";
    }
    @RequestMapping("editor")
    public String editor(Model model, Integer id){

        model.addAttribute("storefronts",storefrontService.list(null,null).getContent());

        model.addAttribute("relocationPrice",priceService.get(PriceType.relocation).getPrice());
        model.addAttribute("temporaryPrice",priceService.get(PriceType.temporary).getPrice());
        model.addAttribute("difficultPrice",priceService.get(PriceType.difficult).getPrice());
        model.addAttribute("compensatePrice",priceService.get(PriceType.compensate).getPrice());
        model.addAttribute("imposePrice",priceService.get(PriceType.impose).getPrice());
        model.addAttribute("landRewardPrice",priceService.get(PriceType.landReward).getPrice());
        model.addAttribute("signingRewardPrice",priceService.get(PriceType.signingReward).getPrice());
        model.addAttribute("sealRewardPrice",priceService.get(PriceType.sealReward).getPrice());
        model.addAttribute("transitionRewardPrice",priceService.get(PriceType.transitionReward).getPrice());
        model.addAttribute("layer4Price",priceService.get(PriceType.layer4).getPrice());
        model.addAttribute("layer5Price",priceService.get(PriceType.layer5).getPrice());
        model.addAttribute("layer6Price",priceService.get(PriceType.layer6).getPrice());
        model.addAttribute("takeCareOfBuyPrice",priceService.get(PriceType.takeCareOfBuy).getPrice());
        model.addAttribute("equallySharedPrice",priceService.get(PriceType.equallyShared).getPrice());
        model.addAttribute("errorAreaPriceBasicPrice",priceService.get(PriceType.errorAreaPriceBasic).getPrice());
        model.addAttribute("errorAreaPriceSecondaryPrice",priceService.get(PriceType.errorAreaPriceSecondary).getPrice());


        return "calculate-detail";
    }
}
